<?php
class Zend_View_Helper_Minicart extends Zend_View_Helper_Abstract
{
	public function minicart(){
		$result='<div class="minicart-all">';
		$cartHelper=new Model_CartHelper();
		$locs=$cartHelper->getLastestCart();
		$totalMoney=0;
		foreach($locs as $loc){
			
			$result=$result.
			'
				
					<div class="minicart-location"><img src="../img/pin.png"></img>'.$loc['Name'].'</div>	
			';
			$data=$loc['items'];
			$total=0;
			$result=$result.
			'
		<table class="cartTable">
		';
			
			$i=0;
			if ($data!=null){
				foreach($data as $item){
					$i++;
					$itemString=$i.'. '.$item['Name'].'<br />'.$item['Quantity'].' x '.$item['Price'].'đ<br/><hr />';
					$money=$item['Quantity']*$item['Price'];
					$total=$total+$money;
					$re=
					'
				<tr class="cartItem-top">
					<td colspan="3"><span class="cart-id">'.$i.'. '.'</span><span class="cart-name">'.$item['Name'].'</span></td>
				</tr>
				<tr class="cartItem-bottom">
					<td><div class="cart-pricexquantity"><div class="cart-quantity">'.$item['Quantity'].' x </div></td>
					<td><div class="cart-price"> '.$item['Price'].'đ </div></td>
					<td><div class="cart-money">=&nbsp;&nbsp;'.$money.'đ</div></td>
				</tr>
		';
					$result= $result. $re;
				}
				$totalMoney+=$total;
				$result= $result.'
					<tr>
						<td colspan="2"><div class="cart-total-label">Total:</div></td>
						<td><div class="cart-total">=&nbsp;'.$total.'đ</div></td>
					</tr>
					';
					
				$result= $result.'</table>';
					
			}
			else{
				
			}
			
		}
		$result=$result.'<div class="total-sum">TOTAL: '.$totalMoney.'d<div>';
		
		return $result.'<div>';
	}
}